package com.easy.concert.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easy.common.bean.ConresultBean;
import com.easy.common.service.IConresultService;
import com.easy.common.util.Result;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("conresult")

public class ConresultController {
    @Autowired
    IConresultService conresultService;

    @GetMapping("/getConresultById/{id}")
    @GlobalTransactional //分布式事务！！！！！！！！！！！！！！！！！！！！！！！！！
    public Result getConresultById(@PathVariable("id") Integer id) {
        Object obj=conresultService.getConresultById(id);
        return Result.success(obj);
    }

    @PostMapping("/add")
    public Result addConresult(@RequestBody ConresultBean conresultBean) {
        Object obj=conresultService.addConresult(conresultBean);
        return Result.success(obj);
    }

    @PutMapping("/edit")
    public Result updateConresult(@RequestBody ConresultBean conresultBean) {
        Object obj=conresultService.updateConresult(conresultBean);
        return Result.success(obj);
    }
    @DeleteMapping("/deleteConresult/{id}")
    public Result deleteConresult(@PathVariable("id") Integer id) {
        Object obj=conresultService.deleteConresult(id);
        return Result.success(obj);
    }
    @GetMapping("/all")
    public Result getAll(ConresultBean conresultBean) {
        Object obj=conresultService.getAll(conresultBean);
        return Result.success(obj);
    }
    @GetMapping("/page")
    public Result getPage(ConresultBean conresult, Page<ConresultBean> page ){
        conresultService.getPage(conresult,page);
        return Result.success(page);
    }
}
